package com.joven.gateway.config;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author joven_wong
 * 2021/6/22 14:38
 * 全局过滤器
 * 所有的请求都会被过滤，不需要在去找某个路由中加过滤器
 */
//@Component
public class JovenGlobalFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("这里处理自身逻辑");
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
